<?php

namespace App\service\Order;

use App\Models\Orders;
use Godruoyi\Snowflake\Snowflake;

class order
{
    public static function order($user_id,$totalMoney,$discountMoney,$address_id){
        //雪花算法生成
        $snowflake = new Snowflake();
        $order_sn= $snowflake->id();
        $data=[
            'user_id'=>$user_id,
            'order_sn'=>$order_sn,
            'goods_money'=>$totalMoney,
            'total_money'=>$discountMoney,
            'address_id'=>$address_id,
            'created_at'=>date('Y-m-d H:i:s')
        ];
        $order_id= Orders::insertGetId($data);
        return $order_id;
    }
}
